#include <opencv2/opencv.hpp>
#include <iostream>

using namespace  cv;
using namespace std;
int main12(){
    Mat src=imread("D:\\rubberwhale1.png",0);
    Mat hold;
    threshold(src,hold,128,255,CV_THRESH_OTSU);
    //src.release();
    /* Mat erode;*/
    //Mat element(7,7,CV_8UC1,Scalar(1));
    /* Mat element;
    cv::erode(src,erode,element);*/
    //Mat dilate;
    //cv::dilate(src,dilate,element);
    //imshow("src",src);
    //imshow("erode",erode);
    //imshow("dilate",dilate);
    //Mat open,close;
    //morphologyEx(src,close,MORPH_CLOSE,Mat(10,10,CV_8U,Scalar(1)));
    //morphologyEx(src,open,MORPH_OPEN,Mat());
    //imshow("open1",open);
    //morphologyEx(open,open,MORPH_OPEN,Mat(10,10,CV_8U,Scalar(1)));
    //imshow("src",src);
    //imshow("open2",open);
    //imshow("close",close);
    //Mat openclose;
    //morphologyEx(src,openclose,MORPH_OPEN,Mat());
    //morphologyEx(openclose,openclose,MORPH_CLOSE,Mat(5,5,CV_8U,Scalar(1)));
    //imshow("openclose",openclose);
    //Mat closeopen;
    //morphologyEx(src,closeopen,MORPH_CLOSE,Mat());
    //morphologyEx(openclose,closeopen,MORPH_OPEN,Mat(5,5,CV_8U,Scalar(1)));
    //imshow("closeopen",closeopen);
    //Mat GRADIENT;
    //morphologyEx(src,GRADIENT,MORPH_GRADIENT,Mat());
    //imshow("GRADIENT",GRADIENT);
    //Mat ERODE;
    //morphologyEx(src,ERODE,MORPH_ERODE,Mat());
    //imshow("ERODE",ERODE);
    imshow("src",src);
    imshow("hold",hold);
    Mat GRADIENT;
    morphologyEx(src,GRADIENT,MORPH_GRADIENT,Mat());
    imshow("GRADIENT",GRADIENT);

    Mat BLACKHAT;
    morphologyEx(src,BLACKHAT,MORPH_BLACKHAT,Mat());
    imshow("BLACKHAT",BLACKHAT);

    Mat TOPHAT;
    morphologyEx(src,TOPHAT,MORPH_TOPHAT,Mat());
    imshow("TOPHAT",TOPHAT);

    threshold(GRADIENT,GRADIENT,128,255,CV_THRESH_OTSU);
    imshow("GRADIENT2",GRADIENT);

    Mat element1= getStructuringElement(MORPH_ELLIPSE, Size(15, 15));  
     imshow("element1",element1);
    waitKey(0);
    return 0;

}